<?php

// create temporary auto loader function
// that will be used to load pmvc classes
// until the ClassLoader is created below
function temp_pmvc_autoloader($className) {
	if (class_exists($className)) {
		return false;
	}
	$filename = __DIR__.DIRECTORY_SEPARATOR.str_replace("\\", DIRECTORY_SEPARATOR, $className).".class.php";
	if (file_exists($filename)) {
		$realpath = realpath($filename);
		if ($realpath!==false) {
			require_once($realpath);
		} else {
			require_once($filename);
		}
		return true;
	} else {
		return false;
	}
};

// register it
spl_autoload_register("temp_pmvc_autoloader", false);

// add a class loader for the pmvc classes
pmvc\util\ClassUtil::addClassLoadersForPaths(Array(__DIR__));

// unregister the temporary loader
spl_autoload_unregister("temp_pmvc_autoloader");

// register the classpath:// stream wrapper
stream_wrapper_register(pmvc\io\ClasspathStreamWrapper::PROTOCOL, 'pmvc\io\ClasspathStreamWrapper', STREAM_IS_URL);

?>